home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13592 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: solon.com!not-for-mail
  2. From: thads@csn.net (Thad Smith)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  4. Subject: Re: C coding problem
  5. Date: 8 Apr 1996 22:50:57 -0500
  6. Organization: T3 Systems
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4kcmr1$p6e@solutions.solon.com>
  10. References: <4j06na$808@solutions.solon.com> <4jttan$3gf@solutions.solon.com>
  11.  <4jv6st$crf@solutions.solon.com> <4k1qh3$5hn@solutions.solon.com>
  12. Reply-To: ThadSmith@acm.org
  13. NNTP-Posting-Host: solutions.solon.com
  14.  
  15. In article <4kbdq6$ec2@solutions.solon.com>,
  16. VArase@varase.it.luc.edu (Verne Arase) wrote:
  17.  >In article <4k5vrk$a2d@solutions.solon.com>,
  18.  >schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz) wrote:
  19.  >
  20.  > >|> In such and environment, 
  21.  > >|>       *q++ = *p++;
  22.  > >|> loses badly to
  23.  > >|>       q[i] = p[i], ++i;
  24.  > >|> if the hardware indexing works in terms of the objects being
  25.  > >|> referenced.
  26.  > >
  27.  > >Note that indexed addressing often works only for small
  28.  > >powers of two, e.g., x86 family.
  29.  >
  30.  >Why only small powers of two? You mean if the size of each element is a
  31.  >small power of two (so you can use shift rather than multiply)?
  32.  
  33. The x86 family implements indexing of the form  q[regi*4]  (not sure
  34. about syntax), in which the processor performs the multiply by power
  35. of two at the time of address generation.  This is quicker than
  36. performing a separate multiply instruction before the indexed
  37. instruction.
  38.  
  39. Other sizes require explicit mutiplication of indices, separate
  40. maintenance of i*4, or conversion to pointer operations.
  41.  
  42. Thad
  43.